home *** CD-ROM | disk | FTP | other *** search
/ FM Towns: Free Software Collection 8 / FM Towns Free Software Collection 8.iso / t_os / artemis / artsrc2 / gpset.asm < prev    next >
Assembly Source File  |  1994-06-01  |  4KB  |  230 lines

  1. ;    私製ライブラリ・グラフィック篇
  2. ;    (c) MATSUUCHI Ryosuke in Dec,1992
  3. ;
  4. ;    gpset.asm
  5. ;
  6. ;    1992. 6.13(Sat)
  7. ;    1992. 7. 9(Thu)
  8. ;    1992.12.28(Sun)
  9.  
  10.         public    gpset,_gpset
  11.         extrn    _gwrtreg:near
  12.         extrn    __SetVramSeg:near, __AddVramBase_ebx:near
  13.         
  14.         include    grplib.inc
  15.         
  16.         assume    cs:cseg, ds:dseg
  17.  
  18.  
  19. dseg segment dword 'DATA'
  20. dseg ends
  21.  
  22.  
  23. cseg segment dword 'CODE'
  24.  
  25. ;---------------------------------------------------------------
  26. ;    _gpset : 点の描画
  27. ;        in  EAX,EBX : 座標
  28. ;            ECX     : 色
  29. ;            EDX     : 演算指定(0=PSET 4=XOR)
  30. ;
  31. ;    void gpset(int x, int y, int col, int mode)
  32. ;---------------------------------------------------------------
  33.  
  34.  
  35.  
  36.         align    4
  37.  
  38. _gpset        proc
  39.         pushad
  40.         mov    esi,[_nowscrmod]    ;esi に画面モードを入れる
  41.         cmp    si,2
  42.         jle    #end
  43.         cmp    si,4
  44.         jg    #1
  45.         call    gpset_16
  46.         jmp    #end
  47. #1:        cmp    si,8
  48.         jg    #2
  49.         call    gpset_32_1
  50.         jmp    #end
  51. #2:        cmp    si,11
  52.         jg    #3
  53.         call    gpset_32_2
  54.         jmp    #end
  55. #3:        cmp    si,14
  56.         jg    #4
  57.         call    gpset_256
  58.         jmp    #end
  59. #4:        cmp    si,18
  60.         jg    #end
  61.         call    gpset_32_3
  62. #end:        popad
  63.         ret
  64. _gpset        endp
  65.  
  66.  
  67.  
  68. gpset        proc
  69.         push    ebx
  70.         pushfd
  71.         mov    eax,[esp+8+4]        ;eax に x 座標を入れる
  72.         mov    ebx,[esp+8+8]        ;ebx に y 座標を入れる
  73.         mov    ecx,[esp+8+12]        ;ecx に色を入れる
  74.         mov    edx,[esp+8+16]        ;edx に演算指定を入れる
  75.         call    _gpset
  76.         popfd
  77.         pop    ebx
  78.         ret
  79. gpset        endp
  80.  
  81.  
  82.  
  83.         align    4
  84.  
  85.  
  86. ;● PSET のサブルーチン(16色PSET)
  87. ;----------------------------------------------------------------------------
  88.  
  89.  
  90. gpset_16    proc
  91.         mov    esi,eax            ;edi にマスクパターンを入れる
  92.         mov    edi,1111b
  93.         and    esi,7
  94.         lea    esi,[esi*4]
  95.         or    esi,esi
  96.         jz    #1
  97.         xchg    ecx,esi            ;マスクパターンをシフト
  98.         shl    edi,cl            ;ついでにカラーコードも
  99.         shl    esi,cl            ;シフトする。
  100.         xchg    ecx,esi
  101.         and    ecx,edi
  102. #1:        shr    eax,1            ;ebx にアドレスを入れる
  103.         and    eax,0fffffffch
  104.         lea    ebx,[ebx*8]
  105.         lea    ebx,[ebx*8]
  106.         lea    ebx,[ebx*8+eax]
  107.         call    __AddVramBase_ebx
  108.         push    es            ;es を保存
  109.         call    __SetVramSeg        ;es ←書き込みページのセレクタ
  110.         mov    eax,es:[ebx]        ;eax に VRAMの内容を入れる
  111.         or    edx,edx            ;edx(演算指定)により分岐
  112.         jnz    #3
  113.         not    edi            ;PSET演算
  114.         and    eax,edi
  115.         or    eax,ecx
  116.         jmp    #4
  117. #3:        cmp    edx,4
  118.         jnz    #5
  119.         xor    eax,ecx            ;XOR演算
  120.         jmp    #4
  121. #5:        cmp    edx,6
  122.         jnz    #4
  123.         or    ecx,ecx            ;MATTE(0透過)演算
  124.         jz    #6
  125.         not    edi
  126.         and    eax,edi
  127.         or    eax,ecx
  128. #4:        mov    es:[ebx],eax        ;eax の値を VRAM に書き込む
  129. #6:        ;
  130.         pop    es            ;es を復帰
  131.         ret
  132. gpset_16    endp
  133.  
  134.  
  135. ;● PSET のサブルーチン(3万色PSET [512*256ピクセルモード])
  136. ;----------------------------------------------------------------------------
  137.  
  138.  
  139. gpset_32_1    proc
  140.         lea    ebx,[ebx*8]        ;ebx に ebx*512+eax*2 を
  141.         lea    ebx,[ebx*8]        ;入れる(VRAM アドレス)
  142.         lea    ebx,[ebx*4+eax]
  143.         lea    ebx,[ebx*2]
  144.         call    gpset32sub
  145.         ret
  146. gpset_32_1    endp
  147.  
  148.  
  149.  
  150. gpset_32_2    proc
  151.         lea    ebx,[ebx*8]        ;ebx に ebx*1024+eax*2 を
  152.         lea    ebx,[ebx*8]        ;入れる(VRAM アドレス)
  153.         lea    ebx,[ebx*8+eax]
  154.         lea    ebx,[ebx*2]
  155.         call    gpset32sub
  156.         ret
  157. gpset_32_2    endp
  158.  
  159.  
  160. ;● PSET のサブルーチン(256色PSET)
  161. ;----------------------------------------------------------------------------
  162.  
  163.  
  164. gpset_256    proc
  165.         ;★まだ作ってないよーん
  166.         push    ds
  167.         mov    ax,10ch
  168.         mov    ds,ax
  169.         mov    dword ptr ds:[0],0ffffffffh
  170.         pop    ds
  171.         ret
  172. gpset_256    endp
  173.  
  174.  
  175. ;● PSET のサブルーチン(3万色PSET [512*512ピクセルモード])
  176. ;----------------------------------------------------------------------------
  177.  
  178.  
  179. gpset_32_3    proc
  180.         lea    ebx,[ebx*8]        ;ebx に ebx*1024+eax*2 を
  181.         lea    ebx,[ebx*8]        ;入れる(VRAM アドレス)
  182.         lea    ebx,[ebx*8+eax]
  183.         lea    ebx,[ebx*2]
  184.         call    gpset32sub
  185.         ret
  186.         ;;★まだつくってないよーん
  187.         ;push    ds
  188.         ;mov    ax,10ch
  189.         ;mov    ds,ax
  190.         ;mov    word ptr ds:[0],07fffh
  191.         ;pop    ds
  192.         ;ret
  193. gpset_32_3    endp
  194.  
  195.  
  196. ;● 3万色PSET のサブルーチン
  197. ;    ebx にオフセット、edx に演算指定、ecx にカラーコードが
  198. ;    設定されていることを前提に、
  199. ;    ベースオフセット加算、セレクタ設定、VRAM への書き込みを行う。
  200. ;------------------------------------------------------------------------
  201.  
  202. gpset32sub    proc
  203.         ;  in  ebx:画面内アドレス
  204.         call    __AddVramBase_ebx
  205.         push    es            ;es 保存
  206.         call    __SetVramSeg        ;es ← 書き込みページのセレクタ
  207.         or    edx,edx            ;edx(演算指定) により分岐
  208.         jnz    #2
  209.         mov    es:[ebx],cx        ;演算 PSET
  210.         jmp    #3
  211. #2:        cmp    edx,4
  212.         jnz    #4
  213.         xor    es:[ebx],cx        ;演算 XOR
  214.         jmp    #3
  215. #4:        cmp    edx,6
  216.         jnz    #3
  217.         or    cx,cx            ;演算 MATTE (0透過)
  218.         jz    #5
  219.         mov    es:[ebx],cx
  220. #5:        ;
  221. #3:        pop    es            ;es 復帰
  222.         ret
  223. gpset32sub    endp
  224.  
  225.  
  226.  
  227. cseg ends
  228.  
  229. end
  230.